﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace HF.Software.ClassLib
{
    public class AppConfig
    {
        public AppConfig()
        {
            if (!File.Exists(System.Windows.Forms.Application.StartupPath + @"\Config.INI")) return;

            INIHelper INIUnit = new INIHelper(System.IO.Path.Combine(System.Windows.Forms.Application.StartupPath, "Config.INI"));

            this.SYS = new SYS()
            {
                DefalutSellKind = INIUnit.GetKeyValue("SYS", "DefalutSellKind"),
                PrintResult = INIUnit.GetKeyValue("SYS", "PrintResult").Equals("T"),
                NeedCpnID = INIUnit.GetKeyValue("SYS", "NeedCpnID").Equals("T"),
                ShowOK = INIUnit.GetKeyValue("SYS", "ShowOK").Equals("T"),
                ShowFeature = INIUnit.GetKeyValue("SYS", "ShowFeature").Equals("T"),
                ShowSkin = INIUnit.GetKeyValue("SYS", "ShowSkin").Equals("T"),

                SeverPath = INIUnit.GetKeyValue("SYS", "SeverPath"),
                UpdateTime = INIUnit.GetKeyValue("SYS", "UpdateTime"),

                SeverIP = INIUnit.GetKeyValue("SYS", "SeverIP"),
                SeverName = INIUnit.GetKeyValue("SYS", "SeverName"),
                SeverPort = INIUnit.GetKeyValue("SYS", "SeverPort"),
                UserName = INIUnit.GetKeyValue("SYS", "UserName"),
                PassWord = INIUnit.GetKeyValue("SYS", "PassWord")
            };

            this.TIC = new TIC()
            {
                PrinterName = INIUnit.GetKeyValue("TIC", "PrinterName"),
                PrinterPort = INIUnit.GetKeyValue("TIC", "PrinterPort"),
                //PrinterStyle = Convert.ToInt32(INIUnit.GetKeyValue("TIC", "PrinterStyle")),
                PrinterStyle = INIUnit.GetKeyValue("TIC", "PrinterStyle"),
                SleepTime = Convert.ToInt32(INIUnit.GetKeyValue("TIC", "SleepTime")),
                PrintCinema = INIUnit.GetKeyValue("TIC", "PrintCinema").Equals("T"),
                AutoSelectSeat = INIUnit.GetKeyValue("TIC", "AutoSelectSeat").Equals("T"),
                ShowSeatNum = INIUnit.GetKeyValue("TIC", "ShowSeatNum").Equals("T"),
                TurnText = INIUnit.GetKeyValue("TIC", "TurnText").Equals("T"),
                ResetKind = INIUnit.GetKeyValue("TIC", "ResetKind").Equals("T"),
                PricePrec = Convert.ToInt32(INIUnit.GetKeyValue("TIC", "PricePrec")),
                ShowPrice = INIUnit.GetKeyValue("TIC", "ShowPrice").Equals("T"),
                HallSort = INIUnit.GetKeyValue("TIC", "HallSort").Equals("T"),
                BookPassWord = INIUnit.GetKeyValue("TIC", "BookPassWord")
            };

            this.MEM = new MEM()
            {
                LocationName = INIUnit.GetKeyValue("MEM", "LocationName"),
                LPTPort = INIUnit.GetKeyValue("MEM", "LPTPort"),
                COMPort = INIUnit.GetKeyValue("MEM", "COMPort"),
                BaudRate = Convert.ToInt32(INIUnit.GetKeyValue("MEM", "BaudRate")),
                ReadTime = Convert.ToInt32(INIUnit.GetKeyValue("MEM", "ReadTime")),
                NeedCard = INIUnit.GetKeyValue("MEM", "NeedCard").Equals("T"),
                NeedCardQuery = INIUnit.GetKeyValue("MEM", "NeedCardQuery").Equals("T"),
                PassWord = INIUnit.GetKeyValue("MEM", "PassWord"),
                ID = INIUnit.GetKeyValue("MEM", "ID"),

                CardType = INIUnit.GetKeyValue("MEM", "CardType"),
                Printer = INIUnit.GetKeyValue("MEM", "Printer"),
                PrintWidth = INIUnit.GetKeyValue("MEM", "PrintWidth")
            };

            this.POS = new POS()
            {
                PrinterNo = INIUnit.GetKeyValue("POS", "PrinterNo"),
                LPTPort = INIUnit.GetKeyValue("POS", "LPTPort"),
                DisplayNo = INIUnit.GetKeyValue("POS", "DisplayNo"),
                COMPort = INIUnit.GetKeyValue("POS", "COMPort"),
                BaudRate = INIUnit.GetKeyValue("POS", "BaudRate"),
                SellNo = INIUnit.GetKeyValue("POS", "SellNo"),
                PrintPurchase = INIUnit.GetKeyValue("POS", "PrintPurchase").Equals("T"),
                StoreID = INIUnit.GetKeyValue("POS", "StoreID"),
                HallName = INIUnit.GetKeyValue("POS", "HallName"),
                PosShowSize = INIUnit.GetKeyValue("POS", "PosShowSize"),
                PosShowSite = INIUnit.GetKeyValue("POS", "PosShowSite"),
                ShowSeatTime = Convert.ToInt32(INIUnit.GetKeyValue("POS", "ShowSeatTime")),
                Feature = INIUnit.GetKeyValue("POS", "Feature"),

                SellBookCom = INIUnit.GetKeyValue("POS", "SellBookCom"),
                DoubleScreenState = INIUnit.GetKeyValue("POS", "DoubleScreenState").Equals("T"),
                DoubleScreenSeat = INIUnit.GetKeyValue("POS", "DoubleScreenSeat").Equals("T"),
                DoubleScreenPhotoTimes = INIUnit.GetKeyValue("POS", "DoubleScreenPhotoTimes"),
                ShowPos = INIUnit.GetKeyValue("POS", "ShowPos"),
                ShowSpNo = INIUnit.GetKeyValue("POS", "ShowSpNo").Equals("T"),
                Printer = INIUnit.GetKeyValue("POS", "Printer"),
                PrintWidth = INIUnit.GetKeyValue("POS", "PrintWidth")
            };

            this.SELF = new SELF()
            {
                MediaPath = INIUnit.GetKeyValue("SELF", "MediaPath"),
                MediaFileExtension = INIUnit.GetKeyValue("SELF", "MediaFileExtension"),
                SelfTicketSeatRules = INIUnit.GetKeyValue("SELF", "SelfTicketSeatRules").Equals("T"),
                SelfTicketExitPassWord = INIUnit.GetKeyValue("SELF", "SelfTicketExitPassWord")
            };

            //this.SELF.ExtensionList = new List<string>();
            //string[] fileExt = this.SELF.MediaFileExtension.Split(',');
            //foreach (string s in fileExt)
            //{
            //    this.SELF.ExtensionList.Add(s);
            //}

        }

        public SYS SYS { get; set; }
        public TIC TIC { get; set; }
        public MEM MEM { get; set; }
        public POS POS { get; set; }
        public SELF SELF { get; set; }
    }

    /// <summary>
    /// 系统
    /// </summary>
    public class SYS
    {
        public string DefalutSellKind { get; set; }
        public bool PrintResult { get; set; }
        public bool NeedCpnID { get; set; }
        public bool ShowOK { get; set; }
        public bool ShowFeature { get; set; }
        public bool ShowSkin { get; set; }

        public string SeverPath { get; set; }
        public string UpdateTime { get; set; }
        public string SeverIP { get; set; }
        public string SeverName { get; set; }
        public string SeverPort { get; set; }
        public string UserName { get; set; }
        public string PassWord { get; set; }
    }

    /// <summary>
    /// 售票
    /// </summary>
    public class TIC
    {
        public string PrinterName { get; set; }
        public string PrinterPort { get; set; }
        public string PrinterStyle { get; set; }
        public int SleepTime { get; set; }
        public bool PrintCinema { get; set; }
        public bool AutoSelectSeat { get; set; }
        public bool ShowSeatNum { get; set; }
        public bool TurnText { get; set; }
        public bool ResetKind { get; set; }
        public int PricePrec { get; set; }
        public bool ShowPrice { get; set; }
        public bool HallSort { get; set; }
        public string BookPassWord { get; set; }
    }

    /// <summary>
    /// 会员
    /// </summary>
    public class MEM
    {
        public string LocationName { get; set; }
        public string LPTPort { get; set; }
        public string COMPort { get; set; }
        public int BaudRate { get; set; }
        public int ReadTime { get; set; }
        public bool NeedCard { get; set; }
        public bool NeedCardQuery { get; set; }
        public string PassWord { get; set; }
        public string ID { get; set; }

        public string CardType { get; set; }
        public string Printer { get; set; }
        public string PrintWidth { get; set; }
    }

    /// <summary>
    /// POS机
    /// </summary>
    public class POS
    {
        public string PrinterNo { get; set; }
        public string LPTPort { get; set; }
        public string DisplayNo { get; set; }
        public string COMPort { get; set; }
        public string BaudRate { get; set; }
        public string SellNo { get; set; }
        public bool PrintPurchase { get; set; }
        public string StoreID { get; set; }
        public string HallName { get; set; }
        public string PosShowSize { get; set; }
        public string PosShowSite { get; set; }
        public int ShowSeatTime { get; set; }
        public string Feature { get; set; }

        public string SellBookCom { get; set; }
        public bool DoubleScreenState { get; set; }
        public bool DoubleScreenSeat { get; set; }
        public string DoubleScreenPhotoTimes { get; set; }
        public string ShowPos { get; set; }
        public bool ShowSpNo { get; set; }

        public string Printer { get; set; }
        public string PrintWidth { get; set; }
    }

    /// <summary>
    /// 自助
    /// </summary>
    public class SELF 
    {
        private string _MediaPath;
        public string MediaPath
        {
            get { return _MediaPath; }
            set
            {
                    _MediaPath = value;
            }
        }
        public string MediaFileExtension { get; set; }
        public bool SelfTicketSeatRules { get; set; }
        public string SelfTicketExitPassWord { get; set; }
        //public List<string> ExtensionList { get; set; }
    }

}
